export default {
  methods: {
    $checkForm(formName) {
      let checkResult = false;
      this.$refs[formName].validate((valid) => {
        if (valid) {
          checkResult = true;
        } else {
          checkResult = false;
        }
      });

      return checkResult;
    },

    $asyncCheckForm(formName) {
      let resolveCb = null
      let rejectCb = null

      const promise = new Promise((resolve, reject) => {
        resolveCb = resolve
        rejectCb = reject
      })
      this.$refs[formName].validate((valid) => {
        if (valid) {
          resolveCb(true)
        } else {
          rejectCb(false)
        }
      });

      return promise;
    }
  },
};
